package org.footballmanager.pandafootball.common.job;

import lombok.extern.slf4j.Slf4j;
import org.footballmanager.pandafootball.common.constants.Constants;
import org.footballmanager.pandafootball.system.domain.FootCupbf;
import org.footballmanager.pandafootball.system.domain.enums.BFZT;
import org.footballmanager.pandafootball.system.service.FootCupbfService;
import org.quartz.*;

import java.util.Date;

/**
 * 定时任务类
 * 实现了定时任务的基类
 * 并需要实现其父类里的方法
 *
 * @author chenjian
 * @since 2017年10月18日下午5:17:22
 */
@Slf4j
@PersistJobDataAfterExecution
@DisallowConcurrentExecution
public class CupBfJob implements Job {

    /**
     * 解锁1小时后数据库内的数据
     * @param context 内容
     * @throws JobExecutionException 异常
     */
    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        log.info("OtherJob执行时间: " + new Date());
        JobDataMap map = context.getMergedJobDataMap();
        if(map == null || map.isEmpty()) {
            return;
        }
        FootCupbfService bfservice = (FootCupbfService)map.get("FootCupBfService");
        String id = (String)map.get(Constants.ID);
        if(null != bfservice && id != null && !"".equals(id)){
            FootCupbf bf = bfservice.get(id);
            if(bf.getBfzt().equals(BFZT.NOT)){
                bfservice.makesure(bf, null);
            }
        }
    }

}